//发送get请求获取轮播图图片
import {
    get,
    post,
    put,
    allGet,
    del
} from '../utils/request';

export function loadBanner() {
    return get('http://net-music.penkuoer.com/banner');
}


//发送get请求获取静态分类信息
export function sort() {
    return allGet('http://192.168.12.75:3009/api/v1/product_categories')
}
export function hotShop(id, page = 1) {
    return allGet(`http://192.168.12.75:3009/api/v1/products?product_category=${id}&page=${page}`);
}

//发送get请求获取点击分类数据
export function getData(fuid, page = 1) {
    return get(`/api/v1/admin/products?product_category=${fuid}`, {
        page,
    });
}

// 添加购物车数据
export function postCart(id, num) {
    return post('/api/v1/shop_carts', {
        product: id,
        quantity: num
    })
}

// 取购物车数据
export function getCart() {
    return get('/api/v1/shop_carts')
}

// 删除购物车数据
export function delCart(id) {
    return del(`/api/v1/shop_carts/${id}`)
}

// 地址新增
export function postAddress(data) {
    return post("/api/v1/addresses", {
        receiver: data.name,
        mobile: data.tel,
        regions: data.province + data.city + data.county,
        address: data.addressDetail,
        listdatas: data.isDefault,
    })
}

// 获取地址
export function getAddress() {
    return get("/api/v1/addresses")
}

// 获取单条数据
export function getdanAdd(id) {
    return get(`/api/v1/addresses/${id}`)
}